﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using OpenExpressApp.Editors;
using System.Windows.Data;
using Csla.Wpf;
using System.Windows;
using OpenExpressApp.WPF;


namespace OpenExpressApp.Module.WPF.Editors
{
    /// <summary>
    /// “备注”属性的编辑器。
    /// </summary>
    public class MemoPropertyEditor : ButtonPropertyEditor
    {
        public MemoPropertyEditor(BusinessObjectPropertyInfo propertyInfo, IObjectView view)
            : base(propertyInfo, view) { }

        /// <summary>
        /// 点击按钮时，弹出一个比较大的TextBox窗口对某属性进行编辑
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnButtonClick(RoutedEventArgs e)
        {
            TextBox edtInfo = new TextBox()
            {
                AcceptsReturn = true,
               
            };
            edtInfo.Text = (string)this.PropertyValue;

            bool? result = DialogWorkspace.ShowView(edtInfo, new DialogOptions()
            {
                AllowResize = true,
                DialogTitle = "编辑" + PropertyInfo.Label,
                DialogSize = new Size(600, 400),
                HideOkCancelButtons = IsReadOnly,  
            }, null);

            if ((result.Value) && !IsReadOnly)
            {
                PropertyValue = edtInfo.Text;
            }
        }
    }
}